var log4js = require('log4js');
var fs = require('node-fs');
var path = require('path');

var CONSTS = require('../consts');

//创建logs目录
var logs = path.join(__dirname, CONSTS.APP.LOGPATH);
if (!fs.existsSync(logs))
    fs.mkdirSync(logs)

// logger configure
log4js.configure({
    appenders: [{
        type: 'console'
        //category: 'console'   //console端显示,则注掉
    }, {
        type: 'dateFile',
        filename: 'logs/project.log',
        pattern: '_yyyy-MM-dd',
        maxLogSize: 1024 * 1024,
        alwaysIncludePattern: true,
        backups: 4,
        category: 'logger'
    }],
    replaceConsole: true,
    levels: {
        dateFileLog: 'INFO'
    }
});

module.exports = log4js.getLogger('logger');